package com.wiloon.androidx;

import android.os.Bundle;
import android.view.View;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.ProgressBar;

import org.apache.log4j.Logger;


/**
 * Created by wangyue on 8/13/2014.
 */

public class ProgressBarActivity extends BaseActivity {
    private static final Logger logger = Logger.getLogger(ProgressBarActivity.class);

    @Override
    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        logger.debug("on create.");
        setContentView(R.layout.progress_bar_activity);
        final ProgressBar pb = (ProgressBar) findViewById(R.id.progressBarFoo);
        pb.setMax(100);
        Button btn = (Button) findViewById(R.id.btnProgress);
        btn.setOnClickListener(new Button.OnClickListener() {
            @Override
            public void onClick(View v) {
                logger.debug("pb button clicked.");

                Thread thread = new Thread(new Runnable() {
                    @Override
                    public void run() {
                        pb.setSecondaryProgress(70);
                        for (int i = 0; i < 100; i++) {
                            try {
                                Thread.sleep(10);
                            } catch (InterruptedException e) {
                                e.printStackTrace();
                            }
                            logger.debug("pb index=" + i);
                            pb.setProgress(i);
                        }
                    }
                });
                thread.start();
            }
        });


    }
}
